
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>跨域问题 · introduce</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../index.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="router-lazyload.html" />
    
    
    <link rel="prev" href="env.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    引导
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="vscode.html">
            
                <a href="vscode.html">
            
                    
                    Vscode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="jsdoc.html">
            
                <a href="jsdoc.html">
            
                    
                    Jsdoc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="webpack.html">
            
                <a href="webpack.html">
            
                    
                    Webpack
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="router.html">
            
                <a href="router.html">
            
                    
                    路由和侧边栏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="env.html">
            
                <a href="env.html">
            
                    
                    环境变量
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.7" data-path="cors.html">
            
                <a href="cors.html">
            
                    
                    跨域问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="router-lazyload.html">
            
                <a href="router-lazyload.html">
            
                    
                    路由懒加载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="icons.html">
            
                <a href="icons.html">
            
                    
                    图标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="i18n.html">
            
                <a href="i18n.html">
            
                    
                    国际化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="eslint.html">
            
                <a href="eslint.html">
            
                    
                    ESLint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="permission.html">
            
                <a href="permission.html">
            
                    
                    权限验证
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="style.html">
            
                <a href="style.html">
            
                    
                    样式
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >跨域问题</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x8DE8;&#x57DF;&#x95EE;&#x9898;">&#x8DE8;&#x57DF;&#x95EE;&#x9898;</h1>
<p>&#x5E73;&#x65F6;&#x88AB;&#x95EE;&#x5230;&#x6700;&#x591A;&#x7684;&#x95EE;&#x9898;&#x8FD8;&#x662F;&#x5173;&#x4E8E;&#x8DE8;&#x57DF;&#x7684;&#xFF0C;&#x5176;&#x5B9E;&#x8DE8;&#x57DF;&#x95EE;&#x9898;&#x771F;&#x7684;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x5F88;&#x96BE;&#x89E3;&#x51B3;&#x7684;&#x95EE;&#x9898;&#x3002;&#x8FD9;&#x91CC;&#x6211;&#x6765;&#x7B80;&#x5355;&#x603B;&#x7ED3;&#x4E00;&#x4E0B;&#x6211;&#x63A8;&#x8350;&#x7684;&#x51E0;&#x79CD;&#x8DE8;&#x57DF;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#x3002;</p>
<p>&#x6211;&#x6700;&#x63A8;&#x8350;&#x7684;&#x4E5F;&#x662F;&#x6211;&#x5DE5;&#x4F5C;&#x4E2D;&#x5728;&#x4F7F;&#x7528;&#x7684;&#x65B9;&#x5F0F;&#x5C31;&#x662F;&#xFF1A; <code>cors</code> &#x5168;&#x79F0;&#x4E3A; Cross Origin Resource Sharing&#xFF08;&#x8DE8;&#x57DF;&#x8D44;&#x6E90;&#x5171;&#x4EAB;&#xFF09;&#x3002;&#x8FD9;&#x79CD;&#x65B9;&#x6848;&#x5BF9;&#x4E8E;&#x524D;&#x7AEF;&#x6765;&#x8BF4;&#x6CA1;&#x6709;&#x4EC0;&#x4E48;&#x5DE5;&#x4F5C;&#x91CF;&#xFF0C;&#x548C;&#x6B63;&#x5E38;&#x53D1;&#x9001;&#x8BF7;&#x6C42;&#x5199;&#x6CD5;&#x4E0A;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x533A;&#x522B;&#xFF0C;&#x5DE5;&#x4F5C;&#x91CF;&#x57FA;&#x672C;&#x90FD;&#x5728;&#x540E;&#x7AEF;&#x8FD9;&#x91CC;&#x3002;&#x6BCF;&#x4E00;&#x6B21;&#x8BF7;&#x6C42;&#xFF0C;&#x6D4F;&#x89C8;&#x5668;&#x5FC5;&#x987B;&#x5148;&#x4EE5; <code>OPTIONS</code> &#x8BF7;&#x6C42;&#x65B9;&#x5F0F;&#x53D1;&#x9001;&#x4E00;&#x4E2A;&#x9884;&#x8BF7;&#x6C42;&#xFF08;&#x4E5F;&#x4E0D;&#x662F;&#x6240;&#x6709;&#x8BF7;&#x6C42;&#x90FD;&#x4F1A;&#x53D1;&#x9001; options&#xFF0C;&#x5C55;&#x5F00;&#x4ECB;&#x7ECD; <a href="https://panjiachen.github.io/awesome-bookmarks/blog/cs.html#cors" target="_blank">&#x70B9;&#x6211;</a>&#xFF09;&#xFF0C;&#x901A;&#x8FC7;&#x9884;&#x68C0;&#x8BF7;&#x6C42;&#x4ECE;&#x800C;&#x83B7;&#x77E5;&#x670D;&#x52A1;&#x5668;&#x7AEF;&#x5BF9;&#x8DE8;&#x6E90;&#x8BF7;&#x6C42;&#x652F;&#x6301;&#x7684; <code>HTTP</code> &#x65B9;&#x6CD5;&#x3002;&#x5728;&#x786E;&#x8BA4;&#x670D;&#x52A1;&#x5668;&#x5141;&#x8BB8;&#x8BE5;&#x8DE8;&#x6E90;&#x8BF7;&#x6C42;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x518D;&#x4EE5;&#x5B9E;&#x9645;&#x7684; <code>HTTP</code> &#x8BF7;&#x6C42;&#x65B9;&#x6CD5;&#x53D1;&#x9001;&#x90A3;&#x4E2A;&#x771F;&#x6B63;&#x7684;&#x8BF7;&#x6C42;&#x3002;&#x63A8;&#x8350;&#x7684;&#x539F;&#x56E0;&#x662F;&#xFF1A;&#x53EA;&#x8981;&#x7B2C;&#x4E00;&#x6B21;&#x914D;&#x597D;&#x4E86;&#xFF0C;&#x4E4B;&#x540E;&#x4E0D;&#x7BA1;&#x6709;&#x591A;&#x5C11;&#x63A5;&#x53E3;&#x548C;&#x9879;&#x76EE;&#x590D;&#x7528;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x4E00;&#x52B3;&#x6C38;&#x9038;&#x7684;&#x89E3;&#x51B3;&#x4E86;&#x8DE8;&#x57DF;&#x95EE;&#x9898;&#xFF0C;&#x800C;&#x4E14;&#x4E0D;&#x7BA1;&#x662F;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x8FD8;&#x662F;&#x6B63;&#x5F0F;&#x73AF;&#x5883;&#x90FD;&#x80FD;&#x65B9;&#x4FBF;&#x7684;&#x4F7F;&#x7528;&#x3002;&#x8BE6;&#x7EC6; <a href="https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS" target="_blank">MDN &#x6587;&#x6863;</a></p>
<p>&#x4F46;&#x603B;&#x6709;&#x540E;&#x7AEF;&#x89C9;&#x5F97;&#x9EBB;&#x70E6;&#x4E0D;&#x60F3;&#x8FD9;&#x4E48;&#x641E;&#xFF0C;&#x90A3;&#x7EAF;&#x524D;&#x7AEF;&#x4E5F;&#x662F;&#x6709;&#x89E3;&#x51B3;&#x65B9;&#x6848;&#x7684;&#x3002;</p>
<p>&#x5728; <code>dev</code> &#x5F00;&#x53D1;&#x6A21;&#x5F0F;&#x4E0B;&#x53EF;&#x4EE5;&#x4E0B;&#x4F7F;&#x7528; webpack &#x7684; <code>proxy</code> &#x4F7F;&#x7528;&#x4E5F;&#x662F;&#x5F88;&#x65B9;&#x4FBF;&#xFF0C;&#x53C2;&#x7167; <a href="https://www.webpackjs.com/configuration/dev-server/#devserver-proxy" target="_blank">&#x6587;&#x6863;</a> &#x5C31;&#x4F1A;&#x4F7F;&#x7528;&#x4E86;&#xFF0C;&#x697C;&#x4E3B;&#x4E00;&#x4E9B;&#x4E2A;&#x4EBA;&#x9879;&#x76EE;&#x4F7F;&#x7528;&#x7684;&#x8BE5;&#x65B9;&#x6CD5;&#x3002;&#x4F46;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x5728;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x662F;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;&#x7684;&#x3002;&#x5728;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x4E2D;&#x9700;&#x8981;&#x4F7F;&#x7528; <code>nginx</code> &#x8FDB;&#x884C;&#x53CD;&#x5411;&#x4EE3;&#x7406;&#x3002;&#x4E0D;&#x7BA1;&#x662F; <code>proxy</code> &#x548C; <code>nginx</code> &#x7684;&#x539F;&#x7406;&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x901A;&#x8FC7;&#x642D;&#x5EFA;&#x4E00;&#x4E2A;&#x4E2D;&#x8F6C;&#x670D;&#x52A1;&#x5668;&#x6765;&#x8F6C;&#x53D1;&#x8BF7;&#x6C42;&#x89C4;&#x907F;&#x8DE8;&#x57DF;&#x7684;&#x95EE;&#x9898;&#x3002;</p>
<table>
<thead>
<tr>
<th style="text-align:center">&#x5F00;&#x53D1;&#x73AF;&#x5883;</th>
<th>&#x751F;&#x4EA7;&#x73AF;&#x5883;</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">cors</td>
<td>cors</td>
</tr>
<tr>
<td style="text-align:center">proxy</td>
<td>nginx</td>
</tr>
</tbody>
</table>
<p>&#x8FD9;&#x91CC;&#x6211;&#x53EA;&#x63A8;&#x8350;&#x8FD9;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x8DE8;&#x57DF;&#xFF0C;&#x5176;&#x5B83;&#x7684;&#x8DE8;&#x57DF;&#x65B9;&#x5F0F;&#x90FD;&#x8FD8;&#x6709;&#x5F88;&#x591A;&#x4F46;&#x90FD;&#x4E0D;&#x63A8;&#x8350;&#xFF0C;&#x771F;&#x5FC3;&#x4E3B;&#x6D41;&#x7684;&#x4E5F;&#x5C31;&#x8FD9;&#x4E24;&#x79CD;&#x65B9;&#x5F0F;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="env.html" class="navigation navigation-prev " aria-label="Previous page: 环境变量">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="router-lazyload.html" class="navigation navigation-next " aria-label="Next page: 路由懒加载">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"跨域问题","level":"1.7","depth":1,"next":{"title":"路由懒加载","level":"1.8","depth":1,"path":"src/router-lazyload.md","ref":"src/router-lazyload.md","articles":[]},"previous":{"title":"环境变量","level":"1.6","depth":1,"path":"src/env.md","ref":"src/env.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","-lunr","-search","search-pro","-highlight","prism","livereload"],"styles":{"website":"index.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"expandable-chapters":{},"search-pro":{},"livereload":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"introduce","language":"zh-hans","gitbook":"3.2.3","description":"项目搭建、规范、使用示例介绍"},"file":{"path":"src/cors.md","mtime":"2020-07-29T03:04:31.835Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-29T07:02:36.580Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

